package com.app.stick.bind.controller;

import java.util.List;

import com.app.stick.bind.domain.vo.BizPatientBindDeviceVo;
import com.app.stick.bind.domain.vo.BizPatientDeviceListVo;
import com.app.stick.bind.domain.vo.BizPatientDeviceQueryVo;
import com.app.stick.device.domain.BizDeviceInfo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import javax.annotation.Resource;

import org.springframework.web.bind.annotation.*;
import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.ApiResult;
import com.app.common.enums.BusinessType;
import com.app.stick.bind.domain.BizPatientDeviceInfo;
import com.app.stick.bind.service.IBizPatientDeviceInfoService;

/**
 * 患者和设备绑定信息Controller
 *
 * @author app
 * @date 2023-12-18
 */
@Api(value = "患者和设备绑定信息", tags = {"WEB-患者和设备绑定信息接口"})
@RestController
@RequestMapping("/bind/info")
public class BizPatientDeviceInfoController extends BaseController
{
    @Resource
    private IBizPatientDeviceInfoService bizPatientDeviceInfoService;

    /**
     * 查询患者和设备绑定信息列表
     */
    @ApiOperation("查询患者和设备绑定信息列表")
    @GetMapping("/list")
    public ApiResult<List<BizPatientDeviceListVo>> list(BizPatientDeviceQueryVo queryVo)
    {
        startPage();
        List<BizPatientDeviceListVo> list = bizPatientDeviceInfoService.selectBizPatientDeviceInfoList(queryVo);
        return ApiResult.page(list, new PageInfo(list).getTotal());
    }

    /**
     * 获取患者和设备绑定信息详细信息
     */
    @ApiOperation("获取患者和设备绑定信息详细信息")
    @ApiImplicitParam(name = "pdiId", value = "患者和设备绑定信息ID", dataType = "String", dataTypeClass = String.class, required = true)
    @GetMapping(value = "/getInfo/{pdiId}")
    public ApiResult<BizPatientDeviceInfo> getInfo(@PathVariable("pdiId") String pdiId)
    {
        return ApiResult.ok(bizPatientDeviceInfoService.selectBizPatientDeviceInfoByPdiId(pdiId));
    }

    /**
     * 新增患者和设备绑定信息
     */
    @ApiOperation("新增患者和设备绑定信息")
    @Log(title = "患者和设备绑定信息", businessType = BusinessType.INSERT)
    @PostMapping("/bind")
    public ApiResult<Integer> bind(@RequestBody BizPatientBindDeviceVo patientBindDeviceVo)
    {
        return ApiResult.toR(bizPatientDeviceInfoService.bind(patientBindDeviceVo));
    }

    /**
     * 解除患者和设备绑定信息
     * @param pdiId 绑定ID
     * @return {@link ApiResult}<{@link Integer}>
     */
    @ApiOperation("解除患者和设备绑定信息")
    @ApiImplicitParam(name = "pdiId", value = "患者和设备绑定信息ID", dataType = "String", dataTypeClass = String.class, required = true)
    @GetMapping("/unBind/{pdiId}")
    public ApiResult<Integer> unBind(@PathVariable("pdiId") String pdiId) {
        return ApiResult.toR(bizPatientDeviceInfoService.unBind(pdiId));
    }

    /**
     * 查询未绑定的患者列表
     */
    @ApiOperation("查询未绑定的患者列表")
    @GetMapping("/unBindPatientList")
    public ApiResult<List<BizPatientDeviceListVo>> unBindPatientList(BizPatientDeviceQueryVo queryVo)
    {
        List<BizPatientDeviceListVo> list = bizPatientDeviceInfoService.unBindPatient(queryVo);
        return ApiResult.ok(list);
    }

    /**
     * 查询未绑定的设备列表
     */
    @ApiOperation("查询未绑定的设备列表")
    @GetMapping("/unBindDeviceList")
    public ApiResult<List<BizDeviceInfo>> unBindDeviceList(BizDeviceInfo deviceInfo)
    {
        List<BizDeviceInfo> list = bizPatientDeviceInfoService.unBindDevice(deviceInfo);
        return ApiResult.ok(list);
    }
}
